﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

public partial class admin_adconsultingLang : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void addbt_Click(object sender, EventArgs e)
    {

    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {

    }

    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        e.Cancel = true;
        Label id = (Label)this.GridView1.Rows[e.RowIndex].Cells[0].FindControl("id");
        Label lang = (Label)this.GridView1.Rows[e.RowIndex].Cells[1].FindControl("lg");
        connection con = new connection();
        SqlConnection cn = con.connect();
        //xoa ben bang consulting_lang
        SqlCommand mySqlSelect = new SqlCommand("delete from consulting_lang where id = @id and lang = @lang", cn);
        mySqlSelect.CommandType = CommandType.Text;

        SqlParameter idt = new SqlParameter("@id", SqlDbType.BigInt);
        idt.Value = Int64.Parse(id.Text);
        SqlParameter lg = new SqlParameter("@lang", SqlDbType.BigInt);
        lg.Value = Int64.Parse(lang.Text);
        mySqlSelect.Parameters.Add(idt);
        mySqlSelect.Parameters.Add(lg);
        mySqlSelect.ExecuteNonQuery();

        cn.Close();
        SqlDataSource1.DataBind();
        GridView1.DataBind();
    }

    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        e.Cancel = true;
        Label id = (Label)this.GridView1.Rows[e.NewEditIndex].Cells[0].FindControl("id");
        Label lg = (Label)this.GridView1.Rows[e.NewEditIndex].Cells[1].FindControl("lg");
        //Response.Write(id.Text);
        Response.Redirect("Default.aspx?page=edconsultinglang&id=" + id.Text + "&lang="+lg.Text);
    }

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#99ffcc'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;");
        }
    }
}